package com.kjtpay.design_pattern.interpreter;

import java.text.DecimalFormat;

/**
 * 音阶类;TerminalExpression
 */
class Scale extends Expression {
    @Override
    public void execute(String key, double value) {
        String scale = "";
        switch (Integer.parseInt(new DecimalFormat("0").format(value))) {
            case 1:
                scale = "低音";
                break;
            case 2:
                scale = "中音";
                break;
            case 3:
                scale = "高音";
                break;
            default:
                // 什么也不做
                break;
        }
        // 保存解释后的结果，供外部访问
        result = scale;
    }
}
